﻿using System;
using Microsoft.VisualStudio.DebuggerVisualizers;

[assembly: System.Diagnostics.DebuggerVisualizer(typeof(StringVisualizer.StringVisualizerDebugger), typeof(VisualizerObjectSource),
Target = typeof(System.String), Description = "Advanced String Visualizer")]
namespace StringVisualizer
{
	public class StringVisualizerDebugger : DialogDebuggerVisualizer
	{
		protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
		{
			string targetString = "null";
			bool nullInd = true;
			if (objectProvider != null && objectProvider.GetObject() != null)
			{
				if (objectProvider.GetObject() == DBNull.Value)
					targetString = "DBNull.Value";
				else
				{
					if (string.IsNullOrEmpty(objectProvider.GetObject().ToString()))
						targetString = "Null or Empty";
					else
					{
						targetString = objectProvider.GetObject().ToString();
						nullInd = false;
					}
				}
			}
			StringVisualizer sv = new StringVisualizer(targetString, nullInd);
			sv.ShowDialog();
		}

		public static void TestAdvancedStringVisualizer(object objectToVisualize)
		{
			VisualizerDevelopmentHost vdh = new VisualizerDevelopmentHost(objectToVisualize, typeof(StringVisualizerDebugger));
			vdh.ShowVisualizer();
		}
	}


}
